<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>商品列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>{$nav}</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i></a>
    </div>
    <div class="x-body x-goods">
      <!--<div class="layui-card-body" style="padding-left: 0;">-->
          <!--<form class="layui-form layui-col-space5" action="{:url('admin/Goods/search')}" method="post">-->
          <!--    <div class="layui-inline layui-show-xs-block">-->
          <!--        {if condition="isset($goodsRes.0.supplier_name)"}-->
          <!--          <input type="hidden" name="supplier" value="not1">-->
          <!--        {/if}-->
          <!--        <input type="text" name="keywords" id="search" value="" placeholder="请输入商品信息" autocomplete="off" class="layui-input">-->
          <!--    </div>-->
          <!--    <div class="layui-inline layui-show-xs-block">-->
          <!--        <button class="layui-btn" id="search-btn"><i class="layui-icon"></i></button>-->
          <!--    </div>-->
          <!--</form>-->
      <!--</div>-->
      <xblock>
        <!--<button class="layui-btn" onclick="x_admin_show('新增商品','add','true')"><i class="layui-icon"></i>新增</button>-->
        <span class="x-right" style="line-height:40px">共有数据：{$count}条</span>
      </xblock>
      
      <div class="layui-table-body layui-table-main" style="width: 100%;">
      <table class="layui-table layui-form">
        <thead>
          <tr>
            <th style="text-align: center;">ID</th>
            <th style="text-align: center;">货号</th>
            <th style="text-align: center;">产品中文名称</th>
            <th style="text-align: center;">品牌</th>
            <th style="text-align: center;">分类</th>
            <th style="text-align: center;">规格</th>
            <th style="text-align: center;">价格</th>
            <th style="text-align: center;">操作</th>
          </tr>
        </thead>
        <tbody style="text-align: center;">
          {volist name="goodsRes" id="goods"}
          <tr>
            <td>{$goods.goods_id}</td>
            <td>{$goods.goods_no}</td>
            <td>{$goods.goods_name}</td>
            <td>{$goods.brand}</td>
            <td>{$goods.name}</td>
            <td>{$goods.specs}</td>
            <td>{$goods.price}</td>
            <td class="td-manage" style="text-align: center;">
              <a title="删除" class='layui-btn layui-btn-xs layui-btn-danger' style="margin: 0px;" onclick="member_del(this,{$goods.goods_id})" href="javascript:;">
                <i class="layui-icon">&#xe640;删除</i>
              </a>
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
      </div>
      <div class="page">
        <div>
          {$goodsRes->render()}
        </div>
      </div>
    </div>
    <script>
      layui.use(['form'], function(){
        form = layui.form;

        form.on('switch(status)', function(data){
          var obj=data.elem;
          var id = data.elem.id;
          var status = data.value;
          $.ajax({
              type:'POST',
              dataType:'json',
              data:{status:status,id:id},
              url:"{:url('Goods/changeStatus')}",
              success:function(o){
                if(o.icon == 1){
                  $(obj).attr('value',1);
                }else{
                  $(obj).attr('value',0);
                }
                layer.msg(o.msg,{icon: o.icon,time:1000});
              }
            });
        });

      });

      //搜索商品
      // $("#search-btn").click(function(){
      //   var keywords = $("#search").val();
      //   $.ajax({
      //         type:'POST',
      //         dataType:'json',
      //         data:{keywords:keywords},
      //         url:"{:url('Goods/search')}",
      //         success:function(o){
                
      //         }
      //   });
      // });

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除该商品吗？',function(index){
              //发异步删除数据
              $.ajax({
                type:'POST',
                dataType:'json',
                data:{id:id},
                url:"{:url('Goods/del')}",
                success:function(o){
                  if(o.icon ==1){
                    $(obj).parents("tr").remove();
                  }
                  layer.msg(o.msg,{icon:o.icon,time:1000});
                }
              });
          });
      }
      /*商品排序*/
      function sort(o){
        var goods_id =$(o).attr('id');
        var sort=$(o).val();
          $.ajax({
            type:'POST',
            dataType:'json',
            data:{goods_id:goods_id,sort:sort},
            url:"{:url('Goods/sort')}",
            success:function(o){
              layer.msg(o.msg,{icon:o.icon,time:1000});
            }
          });
      }
    </script>
  </body>

</html>